﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.WebStite
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (Session["captchaa"] != null)
            {
                string cope = txtCaptcha.Text.Trim();
                if (!string.IsNullOrWhiteSpace(cope))
                {
                    if (Session["captchaa"].ToString().Equals(cope))
                    {
                        //实例化对象 做添加
                        IUserManger userManger = new UserManger();
                        TBLogins tBLogins = new TBLogins()
                        {
                            MobileNumber = txtMobileNumber.Text,
                            Password = txtPassword.Text,
                            UserName = txtUserName.Text
                        };
                        //接受返回值
                        OperResult operResult = userManger.Reg(tBLogins);
                        if (operResult != null)
                        {
                            if (operResult.StatusCode == StatusCode.Succeed)
                            {
                                //为true 做正确提示并跳转
                                PageExtensions.AlertAndRedirect(this, "RegSucceed", operResult.Message, "Login.aspx");
                            }
                            else
                            {
                                //为falst 做错误提示不跳转
                                PageExtensions.Alert(this, "RegWorrd", operResult.Message);
                            }
                        }
                    }
                    else
                    {
                        //为falst 做错误提示不跳转
                        PageExtensions.Alert(this, "RegWorrd", "验证码错误");
                    }
                }
                else
                {
                    //为falst 做错误提示不跳转
                    PageExtensions.Alert(this, "RegWorrd", "验证码为空");
                }
            }
        }
    }
}